package com.zltz.www.newfeaturedemo;

import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.util.Log;

public class MainActivity extends AppCompatActivity implements LeftFragment.OnFragmentInteractionListener,
RightFragment.OnFragmentInteractionListener,MenuFragment.OnFragmentInteractionListener,
        SpinnerFragment.OnFragmentInteractionListener, GSonFragment.OnFragmentInteractionListener{

    private final String TAG = "MainActivity";
    private boolean mIsLargeMode = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Fragment fragment = getSupportFragmentManager().findFragmentByTag("right_fragment");
        mIsLargeMode =  fragment != null;

        DisplayMetrics dm = getResources().getDisplayMetrics();
        int width=dm.widthPixels;
        int height=dm.heightPixels;
        double x = Math.pow(width,2);
        double y = Math.pow(height,2);
        double diagonal = Math.sqrt(x+y);

        int dens=dm.densityDpi;
        double screenInches = diagonal/(double)dens;
        Log.d(TAG,"The screenDensity "+ dens);
        Log.d(TAG,"The screenInches "+ screenInches);

        Log.i(TAG, "Large:" + mIsLargeMode);
    }

    @Override
    public void onFragmentInteraction(Uri uri)
    {

    }

    public boolean isLargeMode()
    {
        return mIsLargeMode;
    }
}
